﻿using System;
using System.Collections.Generic;
using System.Text;

namespace KeyCtrl
{
    static public class Logger
    {
        private static List<LogElement> log;

        static Logger()
        {
            log = new List<LogElement>();
        }

        public static void Log(String message)
        {
            log.Add(new LogElement(message));
        }

        public static void Log(Exception e)
        {
            Log("Exception of type:" + e.GetType().ToString() + " logged with message:" + e.ToString() + " stacktrace:" + e.StackTrace);
        }

        new public static String ToString()
        {
            String ret = "";
            foreach (LogElement elem in log)
                ret += elem.Time.ToString() + ": " + elem.Message + "\n";

            return Utils.TrimLast(ret);
        }
    }

    class LogElement
    {
        public String Message;
        public System.DateTime Time;

        public LogElement(String message)
        {
            Message = message;
            Time = System.DateTime.Now;
        }
    }
}
